<!--回款认款单-->
<template>
  <div>
    <f-search-form ref='search' :more='true' @searchHandler='searchHandler'>
      <f-search-form-item label='回款单号' name='paymentNo' />
      <f-search-form-item label='回款单位' name='customName' />
    </f-search-form>
    <f-table ref='table' rowKey='paymentId' 
             :showSetting='false' 
             setting-key='return_tab2' 
             :tableColumns='columns' 
             :scroll='{x:true}' 
             handler='refundPaymentTab2PageListHandler' 
             :showMultipleBtn='false' 
             :operator='operator' 
             :multiple='multiple'
             :params='queryParam' 
             :api='api.payment'>
        <span slot='paymentState' slot-scope='text, record, index'>
            <a-tag color='#87d068' v-if='text==0'>未提交</a-tag>
            <a-tag color='#108ee9' v-if='text==1'>审批中</a-tag>
            <a-tag color='#EE4B2B' v-if='text==2'>已审批</a-tag>
        </span>
      <span slot='drugType' slot-scope='text, record, index'>
            <a-tag color='#87d068' v-if='text=="ZS"'>招商</a-tag>
            <a-tag color='#108ee9' v-if='text=="ZY"'>自营</a-tag>
      </span>
      <span slot='hkImage' slot-scope='text, record, index'>
          <f-images :value='record.hkImage'></f-images>
        </span>
      <span slot='action' slot-scope='text, record'>
          <template>
            <a @click='startProcess(record.paymentId,"hyAskAmountStartProcessHandler")' v-if='record.paymentState==0'>提交</a>
            <a @click='completeTask(record)' v-if="record.taskDefinitionKey&&record.taskDefinitionKey=='__initiator__'">提交</a>
            <a-divider type='vertical' v-if='record.paymentState==0 || record.taskDefinitionKey=="__initiator__"' />
            <a @click='$refs.returnDetailsDrawer.showDrawer(record)'>明细</a>
            <a-divider type='vertical' />
            <a-dropdown>
             <a class='ant-dropdown-link'>更多<a-icon type='down' /></a>
             <a-menu slot='overlay'>
                 <a-menu-item v-if='record.paymentState!=0'>
                  <a href='javascript:;' @click='processImg(record)'>审批进度</a>
                 </a-menu-item>
                 <a-menu-item v-if="record.paymentState==0||record.taskDefinitionKey=='__initiator__'">
                  <a href='javascript:;' @click="$refs.table.del(record,{handlerName:'hyHkPaymentDeleteHandler',processInstanceId:record.processInstanceId,bankStatementId:record.bankStatementId})">删除</a>
                </a-menu-item>
                <a-menu-item>
                <a href='javascript:;' @click='printPayment(record.paymentId)'>打印认款单</a>
              </a-menu-item>
             </a-menu>
            </a-dropdown>
          </template>
        </span>
    </f-table>
    <process-image ref='processImg' v-if='processImageVisible' :visible.sync='processImageVisible' :processInstanceId='processInstanceId'></process-image>
    <return-details-drawer ref='returnDetailsDrawer'></return-details-drawer>
    <print-modal ref='printModal'></print-modal>
  </div>
</template>
<script>
import api from "../../js/api"

import ProcessImage from "../../../flowable/process/process_image"
import { processMixins } from "@/core/mixins/processMixins"
import ReturnDetailsDrawer from "@/views/module/haiying/order/return/components/return_details_drawer"
import PrintModal from "@/views/module/haiying/print/print_modal"

export default {
  name: "Tab3",
  components: { PrintModal, ReturnDetailsDrawer, ProcessImage },
  mixins: [processMixins],
  data() {
    let me = this
    //操作按钮
    let operator = []
    return {
      api: Object.assign(api, this.api),
      multiple: false,
      deptId: "",
      //列表初始化查询参数
      queryParam: {},
      processImageVisible: false,
      processInstanceId: null,
      params1: {
        deptId: ""
      },
      columns: [
        {
          title: "序号",
          width: "60px",
          align: "left",
          customRender: (text, record, index) => index + 1
        },
        {
          title: "回款单号",
          align: "center",
          width: "80px",
          dataIndex: "paymentNo"
        },
        {
          title: "回款单位",
          align: "left",
          width: "240px",
          ellipsis: true,
          length:40,
          dataIndex: "customName"
        },
        {
          title: "发货金额",
          align: "center",
          width: "80px",
          dataIndex: "saleAmount"
        },
        {
          title: "回款日期",
          align: "center",
          width: "100px",
          dataIndex: "amountDate"
        },
        {
          title: "回款金额",
          align: "center",
          width: "100px",
          dataIndex: "amount"
        },
        {
          title: "回款账户",
          align: "left",
          width: "80px",
          dataIndex: "bankName"
        },
        {
          title: "回款流水号",
          align: "left",
          width: "80px",
          ellipsis: true,
          dataIndex: "bankStatementId"
        },
        {
          title: "制单人",
          align: "center",
          width: "110px",
          dataIndex: "nickName"
        }, {
          title: "制单日期",
          align: "center",
          width: "110px",
          dataIndex: "createTime"
        },
        {
          title: "状态",
          align: "center",
          fixed: "right",
          dataIndex: "paymentState",
          scopedSlots: { customRender: "paymentState" }
        },
        {
          title: "操作",
          align: "center",
          dataIndex: "action",
          fixed: "right",
          width: "140px",
          scopedSlots: { customRender: "action" }
        }
      ],
      operator: operator
    }
  },
  created() {
  },
  methods: {
    setData() {
    },
    /**
     * 查询事件
     * @param searchParams
     */
    searchTable(searchParams) {
      this.queryParam = Object.assign(this.queryParam, searchParams)
      this.$refs.table.refresh(true, searchParams)
    },
    /**
     * 刷新列表
     */
    onLoad() {
      this.$refs.table.refresh()
      this.$emit("changeTab")
    },
    //打印单
    printPayment(paymentId) {
      this.$refs["printModal"].open(paymentId, 6, "CustomRefund")
    },
    processImg(order) {
      this.processInstanceId = order.processInstanceId
      this.processImageVisible = true
    }
  }
}
</script>
supplierBondState